﻿(function ($) {
    $(document).ready(function () {
        $('#cssmenu > ul > li > a').click(function () {
            $('#cssmenu li').removeClass('active');
            $(this).closest('li').addClass('active');
            var checkElement = $(this).next();
            if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
                $(this).closest('li').removeClass('active');
                checkElement.slideUp('normal');
            }
            if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
                $('#cssmenu ul ul:visible').slideUp('normal');
                checkElement.slideDown('normal');
            }
            if ($(this).closest('li').find('ul').children().length == 0) {
                return true;
            } else {
                return false;
            }
        });
    });
})(jQuery);

function UrlParam(key) {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars[key];
}
$(document).on('click', '#SliderShowHide', function () {
    if($('#mainmenubar').is(':hidden'))
        $("#mainmenubar").show();
    else
        $("#mainmenubar").hide();
});
$(document).on('keydown', '.QuotaOnlyDecimalDigits', function (event) {
    if (event.keyCode == 46 || event.keyCode == 110 || event.keyCode == 8 || event.keyCode == 37 ||
          event.keyCode == 39 || event.keyCode == 190 || event.keyCode == 13 || event.keyCode == 9 || (event.keyCode <= 105 && event.keyCode >= 96)) {
    }
    else if (event.keyCode < 48 || event.keyCode > 57) {
        event.preventDefault();
    }
});
$(document).on('keydown', '.QuotaOnlyDecimalDigitsNeg', function (event) {
    if (event.keyCode == 46 || event.keyCode == 110 || event.keyCode == 8 || event.keyCode == 37 || event.keyCode == 189 || event.keyCode == 109 ||
          event.keyCode == 39 || event.keyCode == 190 || event.keyCode == 13 || event.keyCode == 9 || (event.keyCode <= 105 && event.keyCode >= 96)) {
    }
    else if (event.keyCode < 48 || event.keyCode > 57) {
        event.preventDefault();
    }
});
$(document).on('keydown', '.QuotaOnlyDigits', function (event) {
    if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 37 ||
          event.keyCode == 39 || event.keyCode == 13 || event.keyCode == 9 || (event.keyCode <= 105 && event.keyCode >= 96)) {
    }
    else if (event.keyCode < 48 || event.keyCode > 57) {
        event.preventDefault();
    }
});
function isInt(n) {
    return n != "" && !isNaN(n) && Math.round(n) == n;
}
